# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-xiaomi-raphael
pkgdesc="Xiaomi Mi 9T Pro / Redmi K20 Pro"
pkgver=3
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
_carch="arm64"
options="!check !archcheck"
depends="
	linux-xiaomi-raphael
	mkbootimg
	postmarketos-base
	mesa-vulkan-freedreno
"
makedepends="devicepkg-dev"
source="
	deviceinfo
	modules-initfs
"

subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-nonfree-firmware-openrc:nonfree_firmware_openrc
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="Firmware for GPU, WiFi, etc."
	depends="
		firmware-xiaomi-raphael
		firmware-xiaomi-raphael-adreno
		firmware-xiaomi-raphael-adsp
		firmware-xiaomi-raphael-camera
		firmware-xiaomi-raphael-cdsp
		firmware-xiaomi-raphael-ipa
		firmware-xiaomi-raphael-slpi
		firmware-xiaomi-raphael-modem
		firmware-xiaomi-raphael-touchscreen
		firmware-xiaomi-raphael-venus
		firmware-xiaomi-raphael-wlan
		linux-firmware-ath11k
		linux-firmware-qcom
		msm-modem
		pd-mapper
		tqftpserv
"
	mkdir "$subpkgdir"
}

nonfree_firmware_openrc() {
	install_if="$pkgname-nonfree-firmware=$pkgver-r$pkgrel openrc"
	install="$subpkgname.post-install"
	mkdir "$subpkgdir"
}

sha512sums="
657da31ee908264f8f13fe9a15b27c2f2a7bb09828e0e3b827de2cf3c39bdc548ba7c04ef4a7c0153b74e4fac7863a7b93abd09b3264f280cbc69958e3ce8216  deviceinfo
d81350bb2c594d1c922b4eaa5f7ddd94ff5c52d915b6b34e01be2fddc5d624dea77343fab9b168acf889b55daa80a5deace6b81366d579816d5cc73b543a6826  modules-initfs
"
